package com.supermap.dataservice.project.template;

import com.alibaba.dubbo.config.annotation.Service;
import com.supermap.dataservice.mysql.config.DynamicDataSourceContextHolder;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.product.template.ProductTemplateSerivce;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author aqua
 * @description
 * @date 2018年11月08 下午 6:25
 * @email 1301584033@qq.com
 */
@Service
public class ProductTemplateServiceImpl implements ProductTemplateSerivce {

    @Resource
    private ProductTemplateMapper productTemplateMapper;

    @Override
    public JSONUtil getProductGrupByTemplateId(Integer areaCode, Integer templateId) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds1");
        return new JSONUtil().setData(productTemplateMapper.getProductGrupByTemplateId(areaCode,templateId));
    }

    @Override
    public List<Map<String, Object>> getListProductTemplate() {
        // 切换数据源
        DynamicDataSourceContextHolder.setDataSourceKey("ds1");
        return productTemplateMapper.ggetListProductTemplate();
    }
}
